import QtQuick
import QtQuick.Controls

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    Column {
        anchors.fill: parent

        SwipeView {
            id: swipeView
            width: parent.width
            height: parent.height - 30
            currentIndex: pageIndicator.currentIndex

            // 动态加载复杂页面
            Repeater {
                model: ListModel {
                    ListElement { component: "Page1.qml" }
                    ListElement { component: "Page2.qml" }
                    ListElement { component: "Page3.qml" }
                }
                Loader {
                    active: SwipeView.isCurrentItem || SwipeView.isNextItem
                    source: component
                }
            }
        }

        PageIndicator {
            id: pageIndicator
            count: swipeView.count
            currentIndex: swipeView.currentIndex
            anchors.horizontalCenter: parent.horizontalCenter
            y: swipeView.height + 10

            // 动态调整可见性
            visible: count > 1
        }
    }
}
